//引入接口
import getCategoryApi from '@/api/prduct/catefory'

const state={
    getCategoryList1:[],
    getCategoryList2:[],
    getCategoryList3:[],
}
const mutations={
    GETLIST1(state,result){
        state.getCategoryList1=result
        // state.getCategory1Id=result.id
    },
    GETLIST2(state,result){
        state.getCategoryList2=result
      
    },
    GETLIST3(state,result){
        state.getCategoryList3=result
    
    }
}

const actions={
    async getList1({commit}){
       
        let result=await getCategoryApi.getCategory1()
        console.log('1',result.data)
        commit("GETLIST1",result.data)
    },
    async getList2({commit},id){
        this.getCategory3Id=""
        this.getCategory2Id=""
        this.getCategoryList3=[]
        this.getCategoryList2=[]
        let result=await getCategoryApi.getCategory2(id)
        console.log('2',result)
        commit("GETLIST2",result.data)
    },
    async getList3({commit},id){
        this.getCategory3Id="",
        this.getCategoryList3=[]
       
        let result=await getCategoryApi.getCategory3(id)

        commit('GETLIST3',result.data)
    }
    
}


export default {
    namespaced: true,
    state,
    mutations,
    actions
  }